<{include file="Public/top.html" }>
</head>
<body>
<div id="warpper">
    <div class="content">
        <div class="location">积分抽奖</div>
        <div class="ui-tab">
            <{include file="Sign/setNav.html"}>
        </div>
        <div class="SignInBOx">
            <form action="" class="ui-form" id="form">
                <div class="ui-form-item" style="height:auto;">
                    <dl>
                        <label class="ui-label">规则说明：</label>
                        <textarea class="ui-textarea" style="width:220px; height:236px;" name="rule" placeholder="请输入活动规则，换行以‘$’结尾。例如：1、每累计签到7天可获得一次抽奖机会。$2、每月满签可额外获得一次抽奖机会。$"><{$data.SIGN_DIAL_RULE}></textarea>
                    </dl>
                </div>
                <div class="ui-form-item" style="height:auto; vertical-align:top;">
                    <label class="ui-label">积分抽奖底图：</label>
                            <span class="picture_box picture_640">
                                <div class="a-imgBox" id="imgBox1" <{if $data.SIGN_DIAL_PAGE_IMG}> style="display:block;" <{else}> style="display:none;" <{/if}>>
                                    <a href="javascript:void(0);" class="a-close" onclick="removeElement('imgBox1','baseImg1')"></a>
                                    <img src="<{$data.SIGN_DIAL_PAGE_IMG}>" width="215" height="340" id="baseImg1"/>
                                    <input type="hidden" name="pagePic" id="basePic1" value="<{$data.SIGN_DIAL_PAGE_IMG}>" />
                                </div>
                                <div style="margin-top:90px;">
                                    <a href="javascript:void(0);" class="a-upload">
                                        <input type="file" name="file" id="upload1" onclick="upload(1)">
                                    </a>
                                    <i>上传图片</i>
                                    <i>640*1007</i>
                                </div>
                            </span>
                    <label class="ui-label mll00">奖品说明底图：</label>
                            <span class="picture_box picture_640">
                                <div class="a-imgBox" id="imgBox2" <{if $data.SIGN_DIAL_PRIZE_IMG}> style="display:block;" <{else}> style="display:none;" <{/if}>>
                                    <a href="javascript:void(0);" class="a-close" onclick="removeElement('imgBox2','baseImg2')"></a>
                                    <img src="<{$data.SIGN_DIAL_PRIZE_IMG}>" width="215" height="340" id="baseImg2"/>
                                    <input type="hidden" name="prizePic" id="basePic2" value="<{$data.SIGN_DIAL_PRIZE_IMG}>" />
                                </div>
                                <div style="margin-top:90px;">
                                    <a href="javascript:void(0);" class="a-upload">
                                        <input type="file" name="file" id="upload2" onclick="upload(2)">
                                    </a>
                                    <i>上传图片</i>
                                    <i>640*1007</i>
                                </div>
                            </span>
                </div>
            </form>
        </div>
        <div class="integral_btn-group">
            <input type="button" value="提交" class="ui-button" id="btn"/>
        </div>
    </div>
</div>
<{include file="Public/foot.html" }>
</body>
</html>
<script>
    function removeElement(id,src)
    {
        document.getElementById(id).style.display="none";
        //删除图片
        $("#"+src).val('');
    }
    //上传底图
    function upload(i) {
        var uploadPic = $('#upload'+i);
        uploadPic.AjaxFileUpload({
            action: './api.php?m=Api&c=index&a=ajaxUpload&from=IMG_DIAL_ABOUT_BASE',
            onSubmit: function () {
                console.log("开始上传");
            },
            onComplete: function (filename, response) {
                if(parseInt(response.id)>0){
                    layer.msg("上传成功");
                    $('#basePic'+i).val(response.msg);
                    $("#baseImg"+i).attr('src',response.msg);
                    document.getElementById('imgBox'+i).style.display="block";
                }else{
                    console.log(response.msg);
                    layer.msg(response.msg);
                }
            }
        });
    }

    $("#btn").on('click',function () {
        var url = "<{U('Sign/savePageSet')}>";
        var param = $("#form").serialize();
        $.getJSON(url,param,function (data) {
            layer.msg(data.msg);
            if(data.status == 0){
                location.reload();
            }
        });

    });

</script>